﻿using System;
using System.Collections.Generic;
using BotonJXC.Entity;
using ProcessFormulaDAO = BotonJXC.DAO.ProcessFormulaDAO;
using BotonJXC.Util;
using NHibernate.Criterion;

namespace BotonJXC.BLL
{
    public class ProcessFormulaBLL : BaseBLL<ProcessFormulaDAO, ProcessFormula, int>
    {
        public ProcessFormulaBLL()
        {
        }

        public PageModel<ProcessFormula> Find(string formulaName, short formulaType, int start, int count)
        {
            List<ICriterion> criterions = new List<ICriterion>();
            if (!string.IsNullOrEmpty(formulaName))
            {
                criterions.Add(Restrictions.Like("FormulaName", formulaName, MatchMode.Anywhere));
            }
            if (formulaType > 0)
            {
                criterions.Add(Restrictions.Eq("FormulaType", formulaType));
            }
            return Dao.FindByPage(criterions.ToArray(), null, start, count);
        }
    }
}